package thread;

public class ThreadLocalTest {
	static ThreadLocal<Double> tl = new ThreadLocal<Double>();
	public static void main(String[] args) {
		new Thread(){public void run(){a();}}.start();
		new Thread(){public void run(){a();}}.start();
		new Thread(){public void run(){a();}}.start();
	}

	private static void a() {
		double d = Math.random();
		System.out.println(Thread.currentThread().getName()+",a(),"+d);
		tl.set(d);
		b();
	}

	private static void b() {
		System.out.println(Thread.currentThread().getName()+",b(),"+tl.get());
		c();
	}

	private static void c() {
		tl.remove();
		System.out.println(Thread.currentThread().getName()+",c(),"+tl.get());
	}
}
